package edu.jmu.action.sysmanage.menu;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import edu.jmu.action.BaseAction;
import edu.jmu.action.privilege.Permission;
import edu.jmu.bean.system.MenuNode;
import edu.jmu.service.sysmanage.MenuNodeService;
import edu.jmu.utils.MenuNodes2Json;

@Controller 
@ParentPackage("json-default")
@Result(type="json")
@Namespace("/sysmanage")
@Scope(value="prototype")
public class ListMenuAction extends BaseAction<MenuNode>{
	private static final long serialVersionUID = -9111983514698431142L;
	@Resource
	private MenuNodeService menuNodeService;
	
	private String menuNodes;
	private boolean needUrl = false;
	
	@Action(value="munuList",results=@Result(type="json"))
	@Permission(module="sysmanage",privilege="showMenu")
	public String menulist(){
		menuNodes = MenuNodes2Json.menuNode2Json(menuNodeService.getMenuNodes(),needUrl);
		return SUCCESS;
	}

	public String getMenuNodes() {
		return menuNodes;
	}

	
	public void setMenuNodes(String menuNodes) {
		this.menuNodes = menuNodes;
	}
	public void setNeedUrl(boolean needUrl) {
		this.needUrl = needUrl;
	}
	
	
	
	
}
